<?php
include('includes/db/sql.functions.php');
ob_start();
$biobit=get_biobit($bb);
echo '<b>Name: </b>'.$biobit['query'][0][bb_name].'<br/>';
echo '<b>Description: </b>'.$biobit['query'][0][bb_desc].'<br/>';
echo '<b>Link: </b>'.$biobit['query'][0][bb_link].'<br/>';

$EWS=Array();
$RWS=Array();
$SINK=Array();


$biobithws=get_all_hws($bb);



foreach ($biobithws['query'] as $hws => $value){
	$genes=get_genes_from_hws($value[hws_name]);
	if($value[hws_type]=="EHW"){

		$EWS[]=array(hws_name => $value[hws_name], hws_comments => $value[hws_comments],
		hws_linkBB => $value[hws_linkBB], hws_testBy => $value[hws_testBy], genes=>$genes['query']);

	}
	if($value[hws_type]=="RHW"){
		$tp=get_tp_from_rhw($value[hws_name]);
		
		$RWS[]=array(hws_name => $value[hws_name], hws_comments => $value[hws_comments],
		hws_linkBB => $value[hws_linkBB], hws_testBy => $value[hws_testBy],genes=>$genes['query'],targprom =>$tp['query']);

	}
	if($value[hws_type]=="SINK"){

		$SINK[]=array(hws_name => $value[hws_name], hws_comments => $value[hws_comments],
		hws_linkBB => $value[hws_linkBB], hws_testBy => $value[hws_testBy],genes=>$genes['query']);

	}


}


echo "</br>";


?>
<script>$(document).ready(function(){
	$( "#tabs" ).tabs();

});
</script>
<div id="tabs">
<ul>
	<li><a href="#tabs-1">EHW</a></li>
	<li><a href="#tabs-2">RHW</a></li>
	<li><a href="#tabs-3">SINK</a></li>
</ul>
<div id="tabs-1"><?php 
foreach($EWS as $key => $value1){

	echo '<fieldset><legend><b>Name: </b>'.$value1[hws_name].'<br/></legend>';
	echo '<b>Comments: </b>'.$value1[hws_comments].'<br/>';
	echo '<b>linkBB: </b><a href='.$value1[hws_linkBB].'>'.$value1[hws_linkBB].'</a><br/>';
	echo '<b>TestBy: </b>'.$value1[hws_testBy].'<br/>';
	
	foreach($value1[genes] as $a => $b){
		echo "<br/>";
		echo '<b>Gen Name: </b>'.$b[g_name].'<br/>';
		echo "<ul>";
		echo '<li><b>Specie: </b>'.$b[g_species].'</li><br/>';
		echo '<li><b>Cod. Sustance: </b>'.$b[g_codSus].'</li><br/>';
		echo '<li><b>BioBrick link: </b><a target="_blank" href='.$b[g_linkBB].'>'.$b[g_linkBB].'</a></li><br/>';
		echo '<li><b>BD link: </b><a target="_blank" href='.$b[g_linkBD].'>'.$b[g_linkBD].'</a></li><br/>';
		echo '<li><b><a id="'.$b[g_name].'">Show Fasta</a></b><div id="fasta'.$b[g_name].'"><b>Fasta: </b>'.$b[g_Fasta].'</div></li>';
		echo"</ul>";
		echo "<script>";
		echo '
		$("#fasta'.$b[g_name].'").hide();
		$("#'.$b[g_name].'").button();
		$("#'.$b[g_name].'").click(function(){
			$("#fasta'.$b[g_name].'").show();
			$("#'.$b[g_name].'").hide();
			});		
		
		';
		echo "</script>";
	}
	echo '</fieldset>';

}
?></div>
<div id="tabs-2"><?php 
foreach($RWS as $key => $value1){

	echo '<fieldset><legend><b>Name: </b>'.$value1[hws_name].'<br/></legend>';
	echo '<b>Comments: </b>'.$value1[hws_comments].'<br/>';
	echo '<b>linkBB: </b><a target="_blank" href='.$value1[hws_linkBB].'>'.$value1[hws_linkBB].'</a><br/>';
	echo '<b>TestBy: </b>'.$value1[hws_testBy].'<br/>';
	foreach($value1[targprom] as $c => $d){
		echo "<br/>";
		echo '<b>Target Promoter name: </b>'.$d[tp_name].'<br/>';
		echo "<ul>";
		echo '<li><b>Specie: </b>'.$d[tp_species].'</li>';
		echo '<li><b><a id="'.$d[tp_name].'">Show Target Promoter Fasta</a></b><div id="fasta'.$d[tp_name].'"><b>Fasta: </b>'.$d[tp_Fasta].'</div></li>';
		echo"</ul>";
		echo "<script>";
		echo '
		$("#fasta'.$d[tp_name].'").hide();
		$("#'.$d[tp_name].'").button();
		$("#'.$d[tp_name].'").click(function(){
			$("#fasta'.$d[tp_name].'").show();
			$("#'.$d[tp_name].'").hide();
			});		
		
		';
		echo "</script>";
		
	}
	
	foreach($value1[genes] as $a => $b){
		echo "<br/>";
		echo '<b>Gen Name: </b>'.$b[g_name].'<br/>';
		echo "<ul>";
		echo '<li><b>Specie: </b>'.$b[g_species].'</li>';
		echo '<li><b>Cod. Sustance: </b>'.$b[g_codSus].'</li>';
		echo '<li><b>BioBrick link: </b><a target="_blank" href='.$b[g_linkBB].'>'.$b[g_linkBB].'</a></li>';
		echo '<li><b>BD link: </b><a target="_blank" href='.$b[g_linkBD].'>'.$b[g_linkBD].'</a></li>';
		echo '<li><b><a id="'.$b[g_name].'">Show Fasta</a></b><div id="fasta'.$b[g_name].'"><b>Fasta: </b>'.$b[g_Fasta].'</div></li>';
		echo"</ul>";
		echo "<script>";
		echo '
		$("#fasta'.$b[g_name].'").hide();
		$("#'.$b[g_name].'").button();
		$("#'.$b[g_name].'").click(function(){
			$("#fasta'.$b[g_name].'").show();
			$("#'.$b[g_name].'").hide();
			});		
		
		';
		echo "</script>";
	}
	echo '</fieldset>';

}
?></div>
<div id="tabs-3"><?php 
foreach($SINK as $key => $value1){

	echo '<fieldset><legend><b>Name: </b>'.$value1[hws_name].'<br/></legend>';
	echo '<b>Comments: </b>'.$value1[hws_comments].'<br/>';
	echo '<b>linkBB: </b><a target="_blank" href='.$value1[hws_linkBB].'>'.$value1[hws_linkBB].'</a><br/>';
	echo '<b>TestBy: </b>'.$value1[hws_testBy].'<br/>';
	foreach($value1[genes] as $a => $b){
		echo "<br/>";
		echo '<b>Gen Name: </b>'.$b[g_name].'<br/>';
		echo "<ul>";
		echo '<li><b>Specie: </b>'.$b[g_species].'</li>';
		echo '<li><b>Cod. Sustance: </b>'.$b[g_codSus].'</li>';
		echo '<li><b>BioBrick link: </b><a target="_blank" href='.$b[g_linkBB].'>'.$b[g_linkBB].'</a></li>';
		echo '<li><b>BD link: </b><a href='.$b[g_linkBD].'>'.$b[g_linkBD].'</a></li>';
		echo '<li><b><a id="'.$b[g_name].'">Show Fasta</a></b><div id="fasta'.$b[g_name].'"><b>Fasta: </b>'.$b[g_Fasta].'</div></li>';
		echo"</ul>";
		echo "<script>";
		echo '
		$("#fasta'.$b[g_name].'").hide();
		$("#'.$b[g_name].'").button();
		$("#'.$b[g_name].'").click(function(){
			$("#fasta'.$b[g_name].'").show();
			$("#'.$b[g_name].'").hide();
			});		
		
		';
		echo "</script>";
	}
	echo '</fieldset>';

}
?></div>

</div>
<?php
$content= ob_get_contents();
ob_end_clean();
include_once('template.php');
?>